package uestc.lj.basicPromotion.bitoperation;

/**
 * 判断一个数是否是2的幂次方或4的幂次方
 *
 * @Author:Crazlee
 * @Date:2021/11/28
 */
public class Code02_IsPower {
	public static boolean is2Power(int n) {
		return (n & (n - 1)) == 0;
	}

	public static boolean is4Power(int n) {
		return (n & (n - 1)) == 0 && (n & 0x55555555) == 0;
	}
}
